package com.yuhong.reggie.mapper;

import com.yuhong.reggie.dto.SetmealDto;
import com.yuhong.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface SetMealMapper {
    //删除指定多个id的套餐(实则修改,为删除)
    Integer deleteByIds(@Param("ids") List<Long> ids,
                        @Param("updateUser") Long updateUser,
                        @Param("updateTime") LocalDateTime updateTime);

    @Select("select count(*) from setmeal where category_id=#{cid} and is_deleted=0")
    Integer countByCid(Long cid);
    //保存套餐数据
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code}," +
            "#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0) ")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    Integer save(SetmealDto setmealDto);

    //根据id列表数据查询启用的套餐个数
    Integer conutByIds(@Param("ids") List<Long> ids);

    //根据套餐名称查询套餐数据
    List<Setmeal> findAll(@Param("name") String name);
}
